package com.example.emvoider.base;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by 阿炜啊 on 2020/7/10.
 */

public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements BaseView{

    public P mPresenter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getLayout());
        mPresenter= initPresenter();
        if (mPresenter!=null){

            mPresenter.bindView(this);
        }
        initdata();
        intaview();
    }

    protected abstract void intaview();


    protected abstract void initdata();

    protected abstract P initPresenter();

    protected abstract int getLayout();


    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.onDestory();
        //2.取消V和P层关联
        mPresenter = null;
    }
}
